package com.huluobo.a2210mdmdemo.demo

import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.huluobo.a2210mdmdemo.R

/**
 *  Created by LC on 2025/3/24.
 */

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Demo01() {
    //横向布局
//    Row(
//        //装饰器
//        Modifier
//            //填充最大宽
//            .fillMaxWidth()
//            //点击事件
////            .clickable {
////                Log.i("TagA", "点击了横向布局")
////            }
//            //内边距
//            .padding(20.dp)
//            .background(Color.White, RoundedCornerShape(20.dp)), horizontalArrangement = Arrangement.SpaceBetween,
//        verticalAlignment = Alignment.Top
//    ) {
//        Text(
//            //文本
//            text = "文本框123123123123123123123123123",
//            //文本位置
//            textAlign = TextAlign.Center,
//            //颜色
//            color = colorResource(id = R.color.purple_200),
//            //大小
//            fontSize = 22.sp,
//            //权重
//            fontWeight = FontWeight.Bold,
//            //字符间距
//            letterSpacing = 13.sp,
//            //最大行数
//            maxLines = 1,
//            //超出范围后
//            overflow = TextOverflow.Ellipsis
//        )
//        Text(text = "文本框123123123123123123123123")
//    }


    var name by remember {
        mutableStateOf("")
    }

    var password by remember {
        mutableStateOf("")
    }

    Column(
        horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(20.dp)
    ) {
        //输入框
//        TextField(
//            //输入的值
//            value = name,
//            //当输入值改变的时候,it就是当前输入框中的值
//            onValueChange = { name = it },
//            label = {
//                Text(text = "请输入用户名")
//            },
//            leadingIcon = {
//                //Icon有3种形式,vector是直接添加系统自导的图标
//                Icon(imageVector = Icons.Default.AccountCircle, contentDescription = "")
//                //painter是添加Drawable中的图标 ,使用painterResource来获取drawable文件夹
////                Icon(painter = painterResource(id = R.drawable.ic_launcher_background), contentDescription = "")
//            },
//
//            )
//        TextField(
//            value = password, onValueChange = { password = it },
//            label = {
//                Text(text = "请输入密码")
//            },
//            trailingIcon = {
//                Icon(
//                    painter = painterResource(id = R.drawable.ic_action_eye),
//                    contentDescription = "",
//                    modifier = Modifier.size(25.dp)
//                )
//            },
//            shape = RoundedCornerShape(20.dp)
//        )
        OutlinedTextField(value = password, onValueChange = { password = it }, label = {
            Text(text = "请输入密码")
        },
            trailingIcon = {
                Icon(
                    painter = painterResource(id = R.drawable.ic_action_eye),
                    contentDescription = "",
                    modifier = Modifier
                        .size(25.dp)
                        .clickable {
                            Log.i("TagA", "点击了密码按钮")
                        }
                )
            },
            //密文展示
            visualTransformation = PasswordVisualTransformation()
        )

//        Button(onClick = {
//            Log.i("TagA", "点击了按钮")
//        }) {
//            Text(text = "登录")
//        }
//
//        OutlinedButton(onClick = {}) {
//            Text(text = "登录")
//        }
//
//        ElevatedButton(onClick = {}) {
//            Text(text = "登录")
//        }
//
//        TextButton(onClick = {}) {
//            Text(text = "登录")
//        }
//
//        OutlinedIconButton(onClick = {}) {
//            Text(text = "登录")
//        }

        //加载本地图片,和Icon类似
        Image(painter = painterResource(id = R.drawable.ic_launcher_background), contentDescription = "")
        Image(imageVector = Icons.Default.Send, contentDescription = "")

        AsyncImage(
            model = "https://img1.baidu.com/it/u=4214113141,2036563917&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1729098000&t=0662d2b383091882ccdd43ad060de2a7",
            contentDescription = "",
            modifier = Modifier
                //图片尺寸
                .size(300.dp)
                //图片形状,比如圆形图片
                .clip(CircleShape),
            //图片缩放,fit完整展示图片,Crop,填充View
            contentScale = ContentScale.Crop
        )

    }
}